package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.FeePlanPeriodAttrHandler;
import com.iwhalecloud.bss.kite.cucc.service.util.CalculatePkgUsageUtil;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @Description
 * @Author deng.gang
 * @Date 2021/9/29 4:49 下午
 */
@Service
@AttrHandler(FeePlanPeriodAttrHandler.class)
public class FeePlanPeriodAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {

    @Override
    public void handle(KiteAttr attr, KiteInst inst, AttrData data) {
        KiteAttr flowPackage = inst.getAttr("200004074");
        // 如果是年包才进行计算
        if (Objects.nonNull(flowPackage) && KiteStringUtils.equals(flowPackage.getValue(), "100007196")) {
            CalculatePkgUsageUtil.calculatePkgUsage(attr, inst, data);
        }
    }

    @Override
    public void handleStyle(KiteAttr attr, KiteInst inst, AttrData data) {

    }
}
